// picker/picker.js
import { isPlainObject } from './tool'

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    scrollType: {
      type: String,
      value: 'normal'// "link": scroll间联动  "normal": scroll相互独立
    },

    listData: {
      type: Array,
      value: [],
     
    },

    mimuteData:{
      type: Array,
      value: [],
    },
  
    isShowPicker: {
      type: Boolean,
      value: false,
    },
    titleText: {// 标题文案
      type: String,
      value: '倒计时'
    },
    cancelText: {// 取消按钮文案
      type: String,
      value: '取消'
    },
    sureText: {// 确定按钮文案
      type: String,
      value: '确定'
    },
    pickerHeaderStyle: String, // 标题栏样式 view
    sureStyle: String, // 标题栏确定样式  text
    cancelStyle: String, // 标题栏取消样式 text
    titleStyle: String, // 标题栏标题样式  view
    maskStyle: String, // 设置蒙层的样式（详见picker-view） view
    indicatorStyle: String, // 设置选择器中间选中框的样式（详见picker-view） view
  },

  /**
   * 组件的初始数据
   */
  data: {
    pickerWidth:wx.getSystemInfoSync().windowWidth * (851.0/1080.0),
    pickerHeight:wx.getSystemInfoSync().windowWidth * (851.0/1080.0)/(851.0/1003),
    value: [],
    backData: [],
    isOpen: true,
    hour:0,
    mimute:1,
  },
  /**
   * 组件的方法列表
   */
  methods: {
    tapModal() {
      this.properties.isShowPicker = false
      this._closePicker()
    },
    cancle() {
      this.triggerEvent('cancle')
      this._closePicker()
    },
    sure() {
      const { scrollEnd, tempValue } = this.data
      if (!scrollEnd) return
     var model = {
       hour:this.data.hour,
       mimute:this.data.mimute,
     }
      this.triggerEvent('sure', {
        choosedData: model,
        choosedIndexArr: tempValue
      })
      this._closePicker()
    },
    _bindChange(e) {
      const { scrollType } = this.properties
      const { lastValue } = this.data
      let val = e.detail.value
      this.data.hour = this.properties.listData[0][val];
      console.log("hour==",this.data.hour)

    },

    _bindpickend() {
      this.data.scrollEnd = true
    },
    mimutestart() {
      this.data.scrollEnd = false
    },

    mimuteChange(e) {
      const { scrollType } = this.properties
      const { lastValue } = this.data
      let val = e.detail.value
      // this.data.tempValue = val.concat()
    
      this.data.mimute = this.properties.mimuteData[0][val];
      console.log("minute==",this.data.mimute)

    },

    mimutepickend() {
      this.data.scrollEnd = true
    },
    mimutepickstart() {
      this.data.scrollEnd = false
    },

    _openPicker() {
   
      this.data.isFirstOpen = false
      this.setData({
        isOpen: true
      })
    },
    _closePicker() {
      this.setData({
        isOpen: false
      })
    },
  }
})
